package com.xlp.pojo;

import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

public class DataParse {
    public static void main(String[] args) {
        Class<Data> dataClass = Data.class;
        Field[] fields = dataClass.getDeclaredFields();
        for (Field field : fields) {
            System.out.println("------------------");
            Type genericType = field.getGenericType();
            System.out.println(genericType);
            if (genericType instanceof ParameterizedType){
                ParameterizedType type = (ParameterizedType) genericType;
                System.out.println(type.getOwnerType());
                System.out.println(type.getRawType());
                System.out.println(type.getTypeName());
                Type[] actualTypeArguments = type.getActualTypeArguments();
                System.out.println(actualTypeArguments.length);
                for (Type actualTypeArgument : actualTypeArguments) {
                    System.out.println(actualTypeArgument + "--" + actualTypeArgument.getClass());
                   // System.out.println((Class<?>)actualTypeArgument);
                }
                //System.out.println(actualTypeArguments);
            } else {
                System.out.println(field.getName() + " is not ParameterizedType");
            }
            System.out.println(field.getType());
            System.out.println("------------------");
        }
    }
}
